<?php
if ( !defined( "IN_OP" ) )
{
    exit( "You can't access this file directly..." );
}
$ui = new UI();
$tpl = new Template2();
$conf = new Config();
if ( $conf->get( "calcbet" ) == 1 )
{
    $ui->showErrorPage( "<p style='background-color: #005982; color: #FFFFFf; padding:0 15px; '>颁奖过帐中，请稍後再使用本功能！</p>" );
    exit();
}
$tpl->load( array("menu" => "6h_menu.htm","main" => "status.htm", "news" => "news.htm" ) );
$tpl->show( "menu" );
$news = $conf->Get( "news" );
$tpl->set( "newsmessage", $news );
$tpl->show( "news" );
if ( $curruser['enabled'] == 0 || $curruser['enabled'] == 2 )
{
    $ui->showErrorPage( "<p style='background-color: #005982; color: #FFFFFf; padding:0 15px; '>帐号已被暂停使用</p>" );
    exit();
}
$rs = getdb( "select * from lotto where open>='".date( "Y-m-d" )."' order by open" );
if ( $rs->eof )
{
    $ui->showErrorPage( "<p style='background-color: #005982; color: #FFFFFf; padding:0 15px; '>目前没有可以下注期数！</p>" );
    exit();
}
$open = $rs->f['open'];
$round = $rs->f['round'];
$lotto_id = $rs->f['id'];
$conf = new Config();
$stopbet = $conf->get( "stopbet" );
if ( date( "Y-m-d" ) < $open )
{
    $ui->showErrorPage( "<p style='background-color: #005982; color: #FFFFFf; padding:0 15px; '>目前非下单时段</p>" );
    exit();
}
else if ( date( "Y-m-d" ) == $open )
{
    if ( $stopbet <= date( "Hi" ) )
    {
    }
    else if ( date( "Hi" ) <= $conf->get( "startbet" ) )
    {
        $ui->showErrorPage( "<p style='background-color: #005982; color: #FFFFFf; padding:0 15px; '>目前非下单时段</p>" );
        exit();
    }
}
$tpl->set( "open", $open );
$tpl->set( "round", d3( $round ) );
$tpl->set( "lotto_id", $lotto_id );
$rs = getdb( "select * from bet where user_id=".$_SESSION['uid']." and lotto_id=".$lotto_id." order by createtime desc, bettype, numbers" );
if ( $rs->eof )
{
    $tpl->set( "list0", "<tr><td colspan=10 align=center>没有下注资料！</td></tr>" );
}
else
{
    $list = "";
    $amount = 0;
    $payoff = 0;
    $count = 0;
    while ( !$rs->eof )
    {
        $list .= "<tr valign=top>";
        $list .= "<td align=left>".$rs->f['id']."</td>";
        $list .= "<td>".date( "m-d H:i", $rs->f['createtime'] )."</td>";
        $list .= "<td>".GetBetContent( $rs->f['bettype'], $rs->f['numbers'], $rs->f['amount'] )."</td>";
        $list .= "<td>".$g_disk_name[$rs->f['disk']]."</td>";
        $list .= "<td align=left>".show_rate( $rs->f['bettype'], $rs->f['rate'] )."</td>";
        $list .= "<td align=left>".$rs->f['amount']."</td>";
        if ( $rs->f['rame'] == 1 )
        {
            $list .= "<td align=center><font color=red>- 逾时 -</font></td>";
        }
        else if ( $rs->f['rame'] == 2 )
        {
            $list .= "<td align=center><font color=red>- 取消 -</font></td>";
        }
        else if ( $rs->f['rame'] == 3 )
        {
            $list .= "<td align=center><font color=red>- 异常 -</font></td>";
        }
        else if ( $rs->f['rame'] == 4 )
        {
            $list .= "<td align=center><font color=red>- 特连 -</font></td>";
        }
        else
        {
			if($rs->f['bettype']==12)
				$new_payoff=$rs->f['payoff'];
			else
            	$new_payoff = round( ( $rs->f['rate'] - 1 ) * $rs->f['amount'], 0 ) + round( ( 100 - $rs->f['back1'] ) / 100 * $rs->f['amount'], 0 );
            $list .= "<td align=left>".$new_payoff."</td>";
            $amount += $rs->f['amount'];
            $payoff += $new_payoff;
            ++$count;
        }
        $list .= "</tr>";
        $rs->movenext();
    }
    $tpl->set( "list0", $list );
    $tpl->set( "count", $count );
    $tpl->set( "sum_amount", $amount );
    $tpl->set( "sum_payoff", "" );
}
$tpl->show( "main" );
?>